package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.OrderStatusMapper;
import com.shop.pojo.OrderStatus;
import com.shop.service.OrderStatusService;
import com.shop.vo.OrderStatusQueryRequest;
import com.shop.vo.OrderStatusSaveRequest;
import com.shop.vo.OrderStatusUpdateRequest;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;


@Service("orderStatusService")
public class OrderStatusServiceImpl extends ServiceImpl<OrderStatusMapper, OrderStatus> implements OrderStatusService {

    @Override
    public IPage<OrderStatus> page(Page page, OrderStatusQueryRequest request){
        QueryWrapper<OrderStatus> wrapper = OrderStatus.queryWrapper(request);
        return this.page(page,wrapper);
    }

    @Transactional
    @Override
    public void save(OrderStatusSaveRequest request){
        OrderStatus orderStatus = new OrderStatus();
        BeanUtils.copyProperties(request,orderStatus);
        this.save(orderStatus);
    }

    @Transactional
    @Override
    public void update(OrderStatusUpdateRequest request){
        OrderStatus orderStatus = new OrderStatus();
        BeanUtils.copyProperties(request,orderStatus);
        this.updateById(orderStatus);
    }

    @Transactional
    @Override
    public void delete(String id){
        UpdateWrapper<OrderStatus> updateWrapper = new UpdateWrapper();
        this.update(updateWrapper);
    }

}